package com.freestyle.nettychat.session.config;

import com.freestyle.nettychat.chat.service.ChatService;
import com.freestyle.nettychat.session.service.RedisSessionServiceFactory;
import com.freestyle.nettychat.session.service.SessionService;
import com.freestyle.redis.expire.RedisKeyExpirationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;

/**
 * Created by rocklee on 2022/2/4 12:23
 */
@Configuration
public class SessionConfig {
  @Resource
  private RedisTemplate<String,Object> redisTemplate;
  @Resource
  private ChatService chatService;
  @Resource
  private RedisKeyExpirationListener redisKeyExpirationListener;
  @Bean
  public SessionService sessionService(){
    return new RedisSessionServiceFactory(redisTemplate,chatService,redisKeyExpirationListener).buildSessionService();
  }
}
